package com.cssw.fyzb.busi.api.exchange;

import com.cssw.fyzb.busi.service.system.SysParamService;
import com.cssw.fyzb.core.model.dodb.SysParam;
import com.cssw.fyzb.core.model.vo.exchang.SysParamVo;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: zzf
 * @time: 2021/1/11 16:51
 */


@Function(description = "兑换比例", parameters = {
        @Parameter(name = "paramCode", type = Type.String, description = "参数编码", required = false),
})
@Component
public class Proportion implements Action {

    @Autowired
    private SysParamService sysParamService;

    @Override
    public Response execute(Request request) throws Exception {
        String paramCode = request.getString("paramCode");
        SysParam sysParam = sysParamService.findByCode(paramCode);
        SysParamVo sysParamVo = new SysParamVo();
        if (sysParam != null) {
            BeanUtils.copyProperties(sysParam, sysParamVo);
        }
        return Response.success().put("data", sysParamVo);
    }
}
